package extended

import (
	"jvm/instructions/base"
	"jvm/rtda"
)

// IFNULL Branch if reference is null
type IFNULL struct{ base.BranchInstruction }

func (i *IFNULL) Execute(jFrame *rtda.JFrame) {
	ref := jFrame.OperandStack().PopRef()
	if ref == nil {
		base.Branch(jFrame, i.Offset)
	}
}

// IFNONNULL Branch if reference not null
type IFNONNULL struct{ base.BranchInstruction }

func (i *IFNONNULL) Execute(jFrame *rtda.JFrame) {
	ref := jFrame.OperandStack().PopRef()
	if ref != nil {
		base.Branch(jFrame, i.Offset)
	}
}
